package com.ruoyi.web.controller.fs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fs.domain.FsEvidenceRuleItem;
import com.ruoyi.fs.service.IFsEvidenceRuleItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 证据规则项目Controller
 * 
 * @author hero
 * @date 2024-08-25
 */
@RestController
@RequestMapping("/fs/item")
public class FsEvidenceRuleItemController extends BaseController
{
    @Autowired
    private IFsEvidenceRuleItemService fsEvidenceRuleItemService;

    /**
     * 查询证据规则项目列表
     */
    @PreAuthorize("@ss.hasPermi('fs:rule:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsEvidenceRuleItem fsEvidenceRuleItem)
    {
        startPage();
        List<FsEvidenceRuleItem> list = fsEvidenceRuleItemService.selectFsEvidenceRuleItemList(fsEvidenceRuleItem);
        return getDataTable(list);
    }

    /**
     * 导出证据规则项目列表
     */
    @PreAuthorize("@ss.hasPermi('fs:rule:export')")
    @Log(title = "证据规则项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FsEvidenceRuleItem fsEvidenceRuleItem)
    {
        List<FsEvidenceRuleItem> list = fsEvidenceRuleItemService.selectFsEvidenceRuleItemList(fsEvidenceRuleItem);
        ExcelUtil<FsEvidenceRuleItem> util = new ExcelUtil<FsEvidenceRuleItem>(FsEvidenceRuleItem.class);
        util.exportExcel(response, list, "证据规则项目数据");
    }

    /**
     * 获取证据规则项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('fs:rule:query')")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") Long itemId)
    {
        return success(fsEvidenceRuleItemService.selectFsEvidenceRuleItemByItemId(itemId));
    }

    /**
     * 新增证据规则项目
     */
    @PreAuthorize("@ss.hasPermi('fs:rule:add')")
    @Log(title = "证据规则项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsEvidenceRuleItem fsEvidenceRuleItem)
    {
        return toAjax(fsEvidenceRuleItemService.insertFsEvidenceRuleItem(fsEvidenceRuleItem));
    }

    /**
     * 修改证据规则项目
     */
    @PreAuthorize("@ss.hasPermi('fs:rule:edit')")
    @Log(title = "证据规则项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsEvidenceRuleItem fsEvidenceRuleItem)
    {
        return toAjax(fsEvidenceRuleItemService.updateFsEvidenceRuleItem(fsEvidenceRuleItem));
    }

    /**
     * 删除证据规则项目
     */
    @PreAuthorize("@ss.hasPermi('fs:rule:remove')")
    @Log(title = "证据规则项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable Long[] itemIds)
    {
        return toAjax(fsEvidenceRuleItemService.deleteFsEvidenceRuleItemByItemIds(itemIds));
    }
}
